program rec;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  Rectangle = class
    public
      a, b: integer;
      procedure squar; virtual;
      procedure update;
    private
      s: integer;
  end;

  SmartRectangle = class(Rectangle)
    procedure setab(newa, newb: integer);
    procedure squar; override;
  end;


{ Rectangle }

procedure Rectangle.squar;
begin
  writeln(s);
end;

procedure Rectangle.update;
begin
  s:=a*b;
end;

{ SmartRectangle }

procedure SmartRectangle.setab(newa, newb :integer );
begin
  a:=newa;
  b:=newb;
  s:=a*b;
end;

procedure SmartRectangle.squar;
begin
  if (s=a*b) then
    writeln(s)
  else
    writeln('FATAL ERROR');
end;
var
  newa, newb: integer;
  s: Rectangle;
  s1: SmartRectangle;
begin
  writeln('enter a, b to use rectangle');
  readln(newa, newb);
  s:=Rectangle.Create;
  s.a:=newa;
  s.b:=newb;
  s.update;
  s.squar;
  s1:=SmartRectangle.Create;
  s1.setab(newa, newb);
  s1.squar;
  readln;
end.
